import { inject, provide, reactive } from "vue";
import type { OverlayState } from "./types";

export * from "./types";

/**
 * 默认 OverlayState
 */
export function defaultOverlayState(): OverlayState {
    return {
        visible: false,
        text: "",
    };
}

/**
 * 提供 OverlayState
 */
export function provideOverlayState(): OverlayState {
    const overlayState = reactive(defaultOverlayState());

    provide("OverlayState", overlayState);

    return overlayState;
}

/**
 * 注入 OverlayState
 */
export function injectOverlayState(): OverlayState {
    return inject("OverlayState", defaultOverlayState());
}
